﻿using MetaProperties.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading;

namespace MetaProperties.Core.Tests
{
    
    
    /// <summary>
    ///This is a test class for SynchronizationContextContainerTest and is intended
    ///to contain all SynchronizationContextContainerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SynchronizationContextContainerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for SynchronizationContext
        ///</summary>
        [TestMethod()]
        [DeploymentItem("MetaProperties.Core.dll")]
        public void SynchronizationContextTest()
        {
            SynchronizationContextContainer container = new SynchronizationContextContainer(null);
            PrivateObject param0 = new PrivateObject(container);
            SynchronizationContextContainer_Accessor target = new SynchronizationContextContainer_Accessor(param0);
            SynchronizationContext expected = new SynchronizationContext();
            SynchronizationContext actual;
            target.SynchronizationContext = expected;
            actual = target.SynchronizationContext;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for SynchronizationContextContainer Constructor
        ///</summary>
        [TestMethod()]
        public void SynchronizationContextContainerConstructorTest()
        {
            SynchronizationContext context = new SynchronizationContext();
            SynchronizationContextContainer target = new SynchronizationContextContainer(context);
            Assert.AreEqual(context, target.SynchronizationContext);
        }

        /// <summary>
        ///A test for SynchronizationContextContainer Constructor
        ///</summary>
        [TestMethod()]
        public void SynchronizationContextContainerConstructorTest1()
        {
            var testSyncContext = new TestSynchronizationContext();
            SynchronizationContext.SetSynchronizationContext(testSyncContext);
            SynchronizationContextContainer target = new SynchronizationContextContainer();
            Assert.AreEqual(testSyncContext, target.SynchronizationContext);
        }

        private class TestSynchronizationContext : SynchronizationContext
        {
        }
    }
}
